#ifndef TRACKERREQUEST_H
#define TRACKERREQUEST_H

#include <QHttp>
#include "metainfo.h"
#include "torrentpeerdata.h"
class TrackerRequest : public QObject


{
    Q_OBJECT
public:
    TrackerRequest(MetaInfo info, QObject* parent = 0);
    void start();
    QByteArray getInfoHash();
    static QByteArray& getPeerId();
    MetaInfo& getTorrentInfo();
private:
    void generatePeerId();
    void processTrackerResponse(const QByteArray& response);
    bool isTrackerSupported(const QString& trackerAddress);
private slots:
    void httpResponseReceived(bool error);
signals:
    void requestCompleted(QString result);
    void requestError(QString reason);    
    void peersListReceived(QList<TorrentPeerData>& peersList);
private:
    //data
    QHttp& httpClient;
    MetaInfo torrentInfo;
    static QByteArray peerId;
    QByteArray infoHash;
};





#endif // TRACKERREQUEST_H
